#ifndef __DOUBLELINKLIST_H_
#define __DOUBLELINKLIST_H_

#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
#define ElementType void*

struct Node
{
    ElementType value;
    struct Node *next;
    struct Node *prev;
};
typedef struct Node node;

struct DoubleLinkList
{
    node *head;
    node *tail;
    int len;
};
typedef struct DoubleLinkList DLlist;

void InitDLlist(DLlist *list);
node* CreateNode(ElementType element);
void InsertDLlistTail(DLlist *list, ElementType element);
void InsertDLlistHead(DLlist *list, ElementType element);
void InsertByIndex(DLlist *list, int index, ElementType element);
void Travel(DLlist *list, void (*funcPtr)(ElementType));
void ReTravel(DLlist *list, void (*funcPtr)(ElementType));
void RemoveByIndex(DLlist *list, int index);
void RemoveByElement(DLlist *list, ElementType element, bool (*funcPtr)(ElementType, ElementType));
void FreeDLlist(DLlist *list, void (*funcPtr)(ElementType));
DLlist FindByElement(DLlist *list, ElementType element, bool (*funcPtr)(ElementType, ElementType));

#endif